package cn.me.alphamq.nameserver.event.model.service;

import cn.me.alphamq.common.entity.req.ServiceHeartBeatReq;
import cn.me.alphamq.common.event.model.Event;
import cn.me.alphamq.common.model.broker.CommitLogTopicModel;
import cn.me.alphamq.common.model.broker.ConsumeQueueOffsetModel;

import java.util.List;

/**
 * 心跳事件（给 nameserver 发送心跳包时会发生该事件）
 *
 * @author f
 */
public class HeartBeatEvent extends Event {

    /**
     * broker 的版本号，非 broker 的服务实例中，这个值为 0
     */
    private final long version;

    /**
     * broker 中所有 topic 的模型
     */
    private final List<CommitLogTopicModel> commitLogTopicModelList;

    /**
     * broker 中所有消费偏移量的模型
     */
    private final ConsumeQueueOffsetModel consumeQueueOffsetModel;

    public HeartBeatEvent(ServiceHeartBeatReq serviceHeartBeatReq) {
        super(serviceHeartBeatReq.getMsgId());
        this.version = serviceHeartBeatReq.getVersion();
        this.commitLogTopicModelList = serviceHeartBeatReq.getCommitLogTopicModelList();
        this.consumeQueueOffsetModel = serviceHeartBeatReq.getConsumeQueueOffsetModel();
    }

    public long getVersion() {
        return version;
    }

    public List<CommitLogTopicModel> getCommitLogTopicModelList() {
        return commitLogTopicModelList;
    }

    public ConsumeQueueOffsetModel getConsumeQueueOffsetModel() {
        return consumeQueueOffsetModel;
    }
}
